import { ref } from 'vue';
import { IPagination } from '@/types';
export const usePagination = () => {
    const paginationConfig = ref<IPagination>({
        total: 0,
        pageSize: 20, // 每页中显示10条数据
        showSizeChanger: true,
        pageSizeOptions: ['5', '10', '15', '20', '50', '100'], // 每页中显示的数据
        showTotal: (total: number) => `共有 ${total} 条数据`, // 分页中显示总的数据
        current: 1
    });
    //Partial把所有类型变成可选项类型
    const setPaginationConfig = (info: Partial<IPagination>) => {
        paginationConfig.value = {
            ...paginationConfig.value,
            ...info
        };
    };
    return {
        paginationConfig,
        setPaginationConfig
    };
};
